package com.ruoyi.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.SjzTouchRecord;
import com.ruoyi.base.service.ISjzTouchRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 摸金记录Controller
 * 
 * @author ruoyi
 * @date 2025-08-06
 */
@RestController
@RequestMapping("/base/record")
public class SjzTouchRecordController extends BaseController
{
    @Autowired
    private ISjzTouchRecordService sjzTouchRecordService;

    /**
     * 查询摸金记录列表
     */
    @PreAuthorize("@ss.hasPermi('base:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(SjzTouchRecord sjzTouchRecord)
    {
        startPage();
        List<SjzTouchRecord> list = sjzTouchRecordService.selectSjzTouchRecordList(sjzTouchRecord);
        return getDataTable(list);
    }

    /**
     * 导出摸金记录列表
     */
    @PreAuthorize("@ss.hasPermi('base:record:export')")
    @Log(title = "摸金记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SjzTouchRecord sjzTouchRecord)
    {
        List<SjzTouchRecord> list = sjzTouchRecordService.selectSjzTouchRecordList(sjzTouchRecord);
        ExcelUtil<SjzTouchRecord> util = new ExcelUtil<SjzTouchRecord>(SjzTouchRecord.class);
        util.exportExcel(response, list, "摸金记录数据");
    }

    /**
     * 获取摸金记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sjzTouchRecordService.selectSjzTouchRecordById(id));
    }

    /**
     * 新增摸金记录
     */
    @PreAuthorize("@ss.hasPermi('base:record:add')")
    @Log(title = "摸金记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SjzTouchRecord sjzTouchRecord)
    {
        return toAjax(sjzTouchRecordService.insertSjzTouchRecord(sjzTouchRecord));
    }

    /**
     * 修改摸金记录
     */
    @PreAuthorize("@ss.hasPermi('base:record:edit')")
    @Log(title = "摸金记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SjzTouchRecord sjzTouchRecord)
    {
        return toAjax(sjzTouchRecordService.updateSjzTouchRecord(sjzTouchRecord));
    }

    /**
     * 删除摸金记录
     */
    @PreAuthorize("@ss.hasPermi('base:record:remove')")
    @Log(title = "摸金记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sjzTouchRecordService.deleteSjzTouchRecordByIds(ids));
    }
}
